package com.kaifamiao.comparing;

import java.util.logging.Logger;

public class Monkey implements Comparable<Monkey>{

    private static final Logger logger = Logger.getAnonymousLogger();

    private String name; // 猴名
    private int age; // 猴龄
    private int weight; // 猴重
    private int height; // 猴高

    public Monkey(String name, int age, int weight, int height) {
        this.name = name;
        this.age = age;
        this.weight = weight;
        this.height = height;
    }

    @Override
    public String toString() {
        return String.format("(%s,%d,%d,%d)", name, age, weight, height );
    }

    // 比较此对象(this)与指定对象(another)的顺序。
    // 如果该对象(this)小于、等于或大于指定对象(another)，则分别返回负整数、零或正整数
    @Override
    public int compareTo(Monkey another) {
        logger.info( "比较" + this.getName() + "和" + another.getName() );
        if( this.getAge() < another.getAge() ) {
            return -1;
        }

        if( this.getAge() > another.getAge() ) {
            return 1;
        }

        return 0;
    }

    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }

    public int getWeight() {
        return weight;
    }

    public int getHeight() {
        return height;
    }
}
